import { Column, Entity, PrimaryGeneratedColumn } from "typeorm";

@Entity("device", { schema: "charge" })
export class Device {
  @PrimaryGeneratedColumn({ type: "int", name: "id", unsigned: true })
  id: number;

  @Column("varchar", { name: "name", length: 100 })
  name: string;

  @Column("tinyint", { name: "type", comment: "类型", default: () => "'0'" })
  type: number;

  @Column("tinyint", {
    name: "charge_type",
    comment: "充电方式",
    default: () => "'0'",
  })
  chargeType: number;

  @Column("tinyint", {
    name: "port_count",
    comment: "端口数量",
    default: () => "'0'",
  })
  portCount: number;

  @Column("json", {
    name: "port_status",
    nullable: true,
    comment: "保存端口状态",
  })
  portStatus: number[] | null;

  @Column("json", { name: "port_data", nullable: true, comment: "端口数据" })
  portData: any[] | null;

  @Column("tinyint", {
    name: "connect_status",
    comment: "链接状态1：是，0：否",
    default: () => "'0'",
  })
  connectStatus: number;

  @Column("int", {
    name: "online_time",
    comment: "上线时间",
    unsigned: true,
    default: () => "'0'",
  })
  onlineTime: number;

  @Column("int", {
    name: "offline_time",
    comment: "离线时间",
    unsigned: true,
    default: () => "'0'",
  })
  offlineTime: number;

  @Column("int", {
    name: "params_rule",
    comment: "设置参数",
    unsigned: true,
    default: () => "'0'",
  })
  paramsRule: number;

  @Column("int", {
    name: "pricing",
    comment: "收费标准",
    unsigned: true,
    default: () => "'0'",
  })
  pricing: number;

  @Column("tinyint", {
    name: "at_ali",
    comment: "是否已经注册到阿里云",
    default: () => "'0'",
  })
  atAli: number;

  @Column("char", { name: "ali_id", comment: "阿里云的设备id", length: 32 })
  aliId: string;

  @Column("char", {
    name: "ali_secret",
    comment: "阿里云的设备Secret",
    length: 32,
  })
  aliSecret: string;

  @Column("varchar", { name: "ali_product", comment: "阿里云产品", length: 11 })
  aliProduct: string;

  @Column("json", { name: "owners", nullable: true })
  owners: number[] | null;

  @Column("int", {
    name: "station_id",
    comment: "站点id",
    unsigned: true,
    default: () => "'0'",
  })
  stationId: number;

  @Column("int", { name: "admin_id", unsigned: true, default: () => "'0'" })
  adminId: number;

  @Column("char", { name: "sim", comment: "物联网卡", length: 20 })
  sim: string;

  @Column("varchar", { name: "hardware", comment: "硬件", length: 30 })
  hardware: string;

  @Column("varchar", { name: "software", comment: "软件", length: 30 })
  software: string;

  @Column("tinyint", {
    name: "signal",
    comment: "信号强度",
    unsigned: true,
    default: () => "'0'",
  })
  signal: number;

  @Column("tinyint", {
    name: "outage_alarm",
    comment: "0: 正常，1: 断电",
    unsigned: true,
    default: () => "'0'",
  })
  outageAlarm: number;

  @Column("double", {
    name: "longitude",
    comment: "经度",
    precision: 22,
    default: () => "'0'",
  })
  longitude: number;

  @Column("double", {
    name: "latitude",
    comment: "维度",
    precision: 22,
    default: () => "'0'",
  })
  latitude: number;

  @Column("varchar", { name: "address", comment: "地址", length: 100 })
  address: string;

  @Column("tinyint", {
    name: "private",
    comment: "1：私人的",
    default: () => "'0'",
  })
  private: number;

  @Column("varchar", { name: "remark", length: 100 })
  remark: string;

  @Column("int", { name: "create_time", unsigned: true, default: () => "'0'" })
  createTime: number;

  @Column("int", { name: "update_time", unsigned: true, default: () => "'0'" })
  updateTime: number;
}
